
*=============================================================================

*** Setup

version 15
capture log close
set more off
clear all

* Load data
use "$data/01 Raw Data/01 US/STAN0125_US_output.dta" 

*=============================================================================

*** Time Path Question

* No randomization of cost in US survey

* Outcome

/* 
1 Costs remain the same over the entire period
2 Costs are lower initially and higher later
3 Costs are higher initially and lower later
4 Costs are lower initially, higher in the middle, and lower later
*/

gen cpath=.
replace cpath=1 if Q4_4==1
replace cpath=2 if Q4_4==2
replace cpath=3 if Q4_4==3
replace cpath=4 if Q4_4==4
lab var cpath "Dynamic Climate Cost Preferences"
lab define cpath_lab 1 "Constant" 2 "Increasing" 3 "Decreasing" 4 "Inverse U"
lab values cpath cpath_lab
tab cpath

* Recode so that increasing is the baseline
recode cpath (2=1) (1=2) (3=3) (4=4), gen(cpath_inc)
tab cpath_inc
label define cpath_inc_lab 1 "Increasing" 2 "Constant" 3 "Decreasing" 4 "Inverse U" 
label values cpath_inc cpath_inc_lab

* Generate indicators
tab cpath_inc, gen(pref_)
rename pref_1 pref_inc
rename pref_2 pref_const
rename pref_3 pref_dec
rename pref_4 pref_invu

*=============================================================================

*** Ideology (3 groups)

gen lrideo=LRSP_11
lab var lrideo "Left (1)-Right (10) Ideology"

gen ideo_left=.
replace ideo_left=1 if lrideo<6
replace ideo_left=0 if lrideo>=6 & lrideo!=.

gen ideo_middle=.
replace ideo_middle=1 if lrideo==6
replace ideo_middle=0 if lrideo!=6 & lrideo!=.

gen ideo_right=.
replace ideo_right=1 if lrideo>6 
replace ideo_right=0 if lrideo<=6 & lrideo!=.

*=============================================================================

*** Gender

gen female=.
replace female=0 if DEMO_gender==1
replace female=1 if DEMO_gender==2
lab var female "Female"

*=============================================================================

*** Age

gen age=2018-DEMO_AGE
lab var age "Age"

* Drop if age<18
drop if age<18

* Dummies
gen age1834=(age>=18 & age<=34)
gen age3549=(age>=35 & age<=49)
gen age5064=(age>=50 & age<=64)
gen age65above=(age>=65 & age!=.)

* Categories
gen agegroups=.
lab var agegroups "Age Groups"
replace agegroups=1 if age1834==1
replace agegroups=2 if age3549==1
replace agegroups=3 if age5064==1
replace agegroups=4 if age65above==1

lab define agegroups 1 "18-34" 2 "35-49" 3 "50-64" 4 "65+"
lab values agegroups agegroups

*=============================================================================

*** Income

* Quantile groups
recode DEMO_faminc (1/3=1) (4/5=2) (6/9=3) (10/15=4) (else=.), gen(inc_group)
lab define inc_group_lab 1 "Income: Low" 2 "Income: Lower Middle" 3 "Income: Upper Middle" 4 "Income: High"
label values inc_group inc_group_lab
label var inc_group "Income Groups"
tab inc_group

* Dummies
gen income=DEMO_faminc
replace income=. if DEMO_faminc>13
su income, det

gen inc_bin_high=.
replace inc_bin_high=0 if income<=`r(p50)'
replace inc_bin_high=1 if income>`r(p50)' & income!=.
label var inc_bin_high "Income: Above Median"

gen inc_low=0 if income!=.
replace inc_low=1 if income>1 & income<=4 & income!=.

gen inc_med=0 if income!=.
replace inc_med=1 if income>4 & income<=7  & income!=.

gen inc_high=0 if income!=.
replace inc_high=1 if income>7 & income!=.

*=============================================================================

*** Employment

gen unempl=0
replace unempl=1 if DEMO_employ==3 | DEMO_employ==4 | DEMO_employ==5

*=============================================================================

*** Education

/*
Years / Code / Label
16 and less	<1> No formal qualifications
16 and less	<2> Youth training certificate/skillseekers
16 and less	<3> Recognised trade apprenticeship completed
16 and less	<4> Clerical and commercial
16 and less	<5> City & Guilds certificate
17-18	<6> City & Guilds certificate - advanced
17-18	<7> ONC
16 and less	<8> CSE grades 2-5
16 and less	<9> CSE grade 1, GCE O level, GCSE, School Certificate
16 and less	<10> Scottish Ordinary/ Lower Certificate
17-18	<11> GCE A level or Higher Certificate
17-18	<12> Scottish Higher Certificate
19+	<13> Nursing qualification (e.g. SEN, SRN, SCM, RGN)
19+	<14> Teaching qualification (not degree)
19+	<15> University diploma
19+	<16> University or CNAA first degree (e.g. BA, B.Sc, B.Ed)
19+	<17> University or CNAA higher degree (e.g. M.Sc, Ph.D)
19+	<18> Other technical, professional or higher qualification
*/

* Dummies

g less_than_hs=0
replace less_than_hs=1 if DEMO_educ<=3 & DEMO_educ!=.
lab var less_than_hs "Less than HS"

g hs=0
replace hs=1 if DEMO_educ==4 & DEMO_educ!=.
lab var hs "HS graduate"

g some_college_or_assdegr=0
replace some_college_or_assdegr=1 if DEMO_educ==5 | DEMO_educ==6 & DEMO_educ!=.
lab var some_college_or_assdegr "Some college or ass. degree"

g ba_or_more=0
replace ba_or_more=1 if DEMO_educ>=7 & DEMO_educ<=10 & DEMO_educ!=.
lab var ba_or_more "BA or more"

* Categories
gen school_lowtier=0 if DEMO_educ!=.
replace school_lowtier=1 if DEMO_educ<=4

gen school_medtier=0 if DEMO_educ!=.
replace school_medtier=1 if DEMO_educ>4 &  DEMO_educ<7 

gen school_hightier=0 if DEMO_educ!=.
replace school_hightier=1 if DEMO_educ>=7 & DEMO_educ<.

* Ordinal variable
g educ=1 if less_than_hs==1
replace educ=2 if hs==1
replace educ=3 if some_college==1
replace educ=4 if ba_or_more==1
lab def educ 1 "Less than HS" 2 "HS" 3 "Some college" 4 "BA or more" 
lab val educ educ

*=============================================================================

*** Children

gen children=0
replace children=1 if DEMO_children>0

*=============================================================================

*** Conjoint experiment version

* CPC_treatment: Climate Policy Conjoint Type
* 1 Climate Policy Cost Path Conjoint
* 2 Climate Policy Cost Timing Conjoint
recode CPC_treatment (1=1) (2=0), gen(cjt_type_path)
lab var cjt_type_path "Conjoint cost type: path (timing=0)"

tab CPCTC_treatment, nolab
replace CPCTC_treatment=. if CPCTC_treatment==9
lab define tconjv 1 "Double" 2 "Triple" 3 "Quadruple"
label values CPCTC_treatment tconjv

*=============================================================================

*** Saving

compress
save "$data/us_prep_import.dta", replace
